/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://github.com/mineadmin
 */

import type { MaSearchItem } from "@mineadmin/search";
import MaDictSelect from "@/components/ma-dict-picker/ma-dict-select.vue";
import MaRemoteSelect from "@/components/ma-remote-select/index.vue";
import { userList } from "$/attractions/commerce/api/commerceMerchant.ts";

export default function getSearchItems(t: any): MaSearchItem[] {
  return [
    {
      label: "管理员",
      prop: "admin_id",
      render: () => MaRemoteSelect,
      renderProps: {
        api: userList,
        axiosConfig: {
          params: { page: 1, limit: 1000 },
        },
        dataHandle: (response: any) => {
          if (response.code === 200 && response.data && response.data.list) {
            return response.data.list.map((item: any) => ({
              label: item.username || `管理员${item.id}`,
              value: item.id,
            }));
          }
          return [];
        },
        placeholder: "请选择管理员",
        clearable: true,
        filterable: true,
        multiple: false,
        // 无障碍访问属性
        "aria-label": "搜索管理员",
        role: "combobox",
      },
    },
    {
      label: "商户类型",
      prop: "merchant_type",
      render: () => MaDictSelect,
      renderProps: {
        data: [
          { label: "个体户", value: 1 },
          { label: "企业", value: 2 },
          { label: "虚拟商户", value: 3 },
          { label: "合作社", value: 4 },
          { label: "政府单位", value: 5 },
        ],
        placeholder: t("form.pleaseInput", { msg: "商户类型" }),
        clearable: true,
        filterable: true,
        multiple: false,
      },
    },
    {
      label: "法人代表",
      prop: "legal_person",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "法人代表" }) },
    },
    {
      label: "法人电话",
      prop: "legal_person_phone",
      render: "input",
      renderProps: {
        placeholder: t("form.pleaseInput", { msg: "法人联系方式" }),
      },
    },
    {
      label: "法人身份证",
      prop: "legal_person_id_card",
      render: "input",
      renderProps: { multiple: false },
    },
    {
      label: "商户联系人",
      prop: "contact_person",
      render: "input",
      renderProps: {
        placeholder: t("form.pleaseInput", { msg: "商户联系人" }),
      },
    },
    {
      label: "商户电话",
      prop: "contact_phone",
      render: "input",
      renderProps: {
        placeholder: t("form.pleaseInput", { msg: "商户联系电话" }),
      },
    },
    {
      label: "联系邮箱",
      prop: "contact_email",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "联系邮箱" }) },
    },
    {
      label: "商店地址",
      prop: "address",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "商店地址" }) },
    },

    {
      label: "营业执照号",
      prop: "business_license",
      render: "input",
      renderProps: {
        placeholder: t("form.pleaseInput", { msg: "营业执照号" }),
      },
    },
    {
      label: "税务登记号",
      prop: "tax_id",
      render: "input",
      renderProps: { multiple: false },
    },
    {
      label: "开户银行",
      prop: "bank_name",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "开户银行" }) },
    },
    {
      label: "银行账号",
      prop: "bank_account",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "银行账号" }) },
    },
  ];
}
